﻿/* Yet Another Forum.NET
 * Copyright (C) 2006-2013 Jaben Cargman
 * http://www.yetanotherforum.net/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
namespace YAF.Editors
{
    #region Using

    using System;
    using System.Web.UI;

    using YAF.Types;

    #endregion

    /// <summary>
    /// The tiny mce editor.
    /// </summary>
    public abstract class CKEditor : TextEditor
    {
        #region Properties

        /// <summary>
        ///   Gets or sets Text.
        /// </summary>
        public override string Text
        {
            get
            {
                return this._textCtl.InnerText;
            }

            set
            {
                this._textCtl.InnerText = value;
            }
        }

        /// <summary>
        ///   Gets SafeID.
        /// </summary>
        [NotNull]
        protected new string SafeID
        {
            get
            {
                return this._textCtl.ClientID.Replace("$", "_");
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// The editor_ PreRender.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void Editor_PreRender([NotNull] object sender, [NotNull] EventArgs e)
        {
            ScriptManager.RegisterClientScriptInclude(
              this.Page, this.Page.GetType(), "ckeditor", this.ResolveUrl("ckeditor/ckeditor.js"));
            this.RegisterCKEditorCustomJS();
            this.RegisterSmilieyScript();
        }

        /// <summary>
        /// The on init.
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnInit([NotNull] EventArgs e)
        {
            base.OnInit(e);

            this._textCtl.Attributes.CssStyle.Add("width", "100%");
            this._textCtl.Attributes.CssStyle.Add("height", "350px");
        }

        /// <summary>
        /// The register ckeditor custom js.
        /// </summary>
        protected abstract void RegisterCKEditorCustomJS();

        #endregion
    }
}